<?php

abstract class AbstractOrganizationalProperty
{
  
  /**
   * @var OrganizationalUnit
   */
  protected $unit;
  
  /**
   * @var OrganizationalProperty
   */
  protected $property;
  
  /**
   * @var AbstractOrganizationalPropertyType
   */
  protected $type;
  
  /**
   * @var string
   */
  protected $value;

  public function __construct (OrganizationalUnit $unit, OrganizationalProperty $property, AbstractOrganizationalPropertyType $type, $value)
  {
    $this->unit = $unit;
    $this->property = $property;
    $this->type = $type;
    $this->value = $value;
  }

  public function __toString ()
  {
    return $this->property->getDescription();
  }

  public function getValue ()
  {
    return $this->value;
  }
  
  public function getProperty() {
    return $this->property;
  }

  public function getDisplayValue ()
  {
    return $this->type->getDisplayValue($this->value);
  }
  
  public function getFormWidget($options=array()) {
    return $this->type->getFormWidget($options);
  } 
  
  public function getFormWidgetValidator($options=array()) {
    return $this->type->getFormWidgetValidator($options);
  }
  
  public function getFormWidgetLabel() {
    return $this->property->getDescription();
  }
  
  public function getFormWidgetId() {
    return $this->property->getName();
  }
}